/**   
 * Copyright © 2019 eSunny Info. Tech Ltd. All rights reserved.
 * 
 * @Description:TODO(功能)
 * @className Page.java
 * @Package: com.erp.util 
 * @author: yj   
 * @date: 2019年1月16日 下午3:31:42 
 */
package com.erp.util;

import java.util.List;

/**
 * @className Page.java
 * @author yj
 * @Description:TODO( 分页工具类 )
 * @Date 2019年1月16日
 */
public class Page<T> {

	private int currentPage;
	private int pageSize;
	private List<T> list;
	private int total;

	public Page(int currentPage, int pageSize) {
		super();
		this.currentPage = currentPage;
		this.pageSize = pageSize;
	}

	public Page() {
		super();
		// TODO Auto-generated constructor stub
	}
	
	// 总页数
	public int totalPages() {
		return (total + pageSize - 1) / pageSize ;
	}

	// 上一页
	public int upPage() {
		if (currentPage > 1) {
			return currentPage - 1;
		}
		return 1;
	}
	
	// 下一页
	public int nextPage() {
		if (currentPage < totalPages()) {
			return currentPage + 1; 
		}
		return totalPages();
	}
	
	// 总记录数
	
	
	//--------------------- get set -----------------------------------
	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public List<T> getList() {
		return list;
	}

	public void setList(List<T> list) {
		this.list = list;
	}

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}

	@Override
	public String toString() {
		return "Page [currentPage=" + currentPage + ", pageSize=" + pageSize + ", list=" + list + ", total=" + total
				+ "]";
	}

}
